#region 属性
const RingBuffer = preload("res://addons/State_Chart/util/ring_buffer.gd")
var _buffer:RingBuffer = null
var _dirty:bool = false
#endregion
#region 字段
var dirty:bool:
	get:
		return _dirty
#endregion
#region 信号
#endregion

#region 基类方法
#endregion
#region 公共方法
func add_history_entry(frame:int,text:String):
	_buffer.append("[{0}]:{1} \n".format([frame,text]))
	_dirty = true
func add_transition(frame:int,name:String,from:String,to:String):
	add_history_entry(frame,"[»] Transition: {0} from {1} to {2}".format([name,from,to]))
func add_event(frame:int,event:StringName):
	add_history_entry(frame,"[!] Event received: {0}".format([event]))
func add_state_entered(frame:int,state_name:StringName):
	add_history_entry(frame,"[>] State Enter: {0}".format([state_name]))
func add_state_exited(frame:int,state_name:StringName):
	add_history_entry(frame,"[<] State Exit: {0}".format([state_name]))
func clear():
	_buffer.clear()
	_dirty = true
func get_history_text() -> String:
	_dirty = false
	return _buffer.join()
#endregion
#region 私有方法
#endregion
#region 生命周期函数
func _init(maximum_lines:int = 500) -> void:
	_buffer = RingBuffer.new(maximum_lines)
	_dirty = false
#endregion
